package cn.catsdad.exception;

import cn.catsdad.constant.iConstant.IResponseStatus;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;

/**
 * 通用异常
 *
 * @author xuyl
 * @version 1.0 2024/7/14
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Slf4j
public class BaseException extends RuntimeException {

    private int status;

    private String msg;

    private BaseException() {
        this.status = IResponseStatus.ERROR;
    }

    public BaseException(Throwable e) {
        this();
        this.msg = e.getMessage();
        log.error(this.msg, this);
    }

    public BaseException(int status, String msg) {
        this();
        this.status = status;
        this.msg = msg;
        log.error(msg, this);
    }

    public BaseException(String msg) {
        this();
        this.msg = msg;
        log.error(msg, this.fillInStackTrace());
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        status = status;
    }

}
